package com.atcd.oss.demo1.controller;


import com.atcd.oss.demo1.service.ossService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

@Controller
public class ossTestController {

    @Autowired
    private ossService ossService;


    @RequestMapping("/upload")
    @ResponseBody
    public  String test(@RequestPart("headImg") MultipartFile multipartFile,@RequestPart("dir") String dir){

        try {
            return  ossService.Demo(multipartFile,dir);
        } catch (Exception e) {
            e.printStackTrace();
            return "fail";
        }


    }

    @RequestMapping("/fileup")
    public  String test2(){
        return "fileup";
    }
}
